@tool
class_name Bullet
extends RigidBody2D


@export var shape: Shape2D
@export var point_light: PointLight2D

@export var radius: float = 5:
    set(value):
        radius = value
        shape.radius = radius
        point_light.texture_scale = radius / 5
        queue_redraw()

@export var color: Color = Color.GREEN:
    set(value):
        color = value
        queue_redraw()
        

var direction: Vector2
var speed: float
var damage: int
var knockback_force: int
var is_handled: bool



func _process(_delta: float) -> void:
    if not get_viewport_rect().has_point(global_position):
#        ObjPool.idle(self)
        queue_free()


func _draw() -> void:
    draw_circle(Vector2.ZERO, radius, color)


func setup(direction_: Vector2, speed_: float, damage_: int, kb_f: int, radius_: float) -> void:
    direction = direction_
    speed = speed_
    damage = damage_
    knockback_force = kb_f
    radius = radius_


func shoot() -> void:
    apply_impulse(direction * speed)
